// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import com.nokia.meego 1.0
import "Variable.js" as Variable
Component{
    Rectangle{
        id: rectangle_content
        width: 500
        height: subTitle.height + 70
        anchors.right: parent.right
        anchors.left: parent.left
        z:1
        color: "transparent"

        ShadowRectangle{
            id: rect_image
            width: 90
            height: 80
            radius: 5
            anchors.left: parent.left
            anchors.leftMargin: 10
            anchors.verticalCenter: parent.verticalCenter
            anchors.rightMargin: 5
            color: "white"

            ShadowRectangle{
                id: rect_image2
                color: "transparent"
                radius: 5
                anchors.rightMargin: 9
                anchors.leftMargin: 9
                anchors.bottomMargin: 5
                anchors.topMargin: 5
                anchors.fill: parent

                Image {
                    id: image_user
                    y: 6
                    z:1
                    height: 100
                    source: image
                    fillMode: Image.PreserveAspectFit
                    anchors.fill: parent
                    asynchronous: true
//                    onProgressChanged: {
//                        console.debug("Image charger >>" + progress)
//                        if(progress >= 1)
//                        {
//                            console.debug("Image Charger >> " + progress)
//                            progressBar.visible = false
//                        }
//                        else
//                        {
//                            progressBar.visible = true
//                            progressBar.value = progress
//                        }
//                    }
                }

                ProgressBar{
                    id: progressBar
                    height: 30
                    anchors.top: image_user.bottom
                    anchors.topMargin: 1
                    anchors.left: image_user.right
                    anchors.leftMargin: 0
                    anchors.right: image_user.left
                    anchors.rightMargin: 0
                    z:2
                    minimumValue: 0
                    maximumValue: 1
                }
            }

            Text {
                id: text_author
                y: 80
                height: 20
                text: author
                anchors.left: parent.left
                anchors.leftMargin: 0
                anchors.right: parent.right
                anchors.rightMargin: 5
                anchors.top: rect_image2.bottom
                anchors.topMargin: 10
                font.pixelSize: 15
                font.bold: true
                horizontalAlignment: Text.AlignHCenter
                wrapMode: Text.WordWrap
            }


        }

        Rectangle{
            id: rectangle_title
            x: 100
            y: 0
            height: 22
            color: "#db667c"
            anchors.left: parent.left
            anchors.leftMargin: 0
            anchors.right: parent.right
            anchors.rightMargin: 1
            opacity: 0.6
            Text {
                id: info
                x: 292
                text: date
                verticalAlignment: Text.AlignVCenter
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 0
                anchors.top: parent.top
                anchors.topMargin: 0
                anchors.right: parent.right
                anchors.rightMargin: 0
                horizontalAlignment: Text.AlignHCenter
                font.pixelSize: 11
            }

            Text {
                id: title
                x: 0
                text: "#"+pubID
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 0
                anchors.top: parent.top
                anchors.topMargin: 0
                font.family: "MS UI Gothic"
                font.pixelSize: 15
                font.bold: true
            }
        }

        TextArea{
            id: subTitle
            text: texte

            anchors.left: rect_image.right
            anchors.leftMargin: 10
            anchors.verticalCenter: parent.verticalCenter
            wrapMode: Text.WordWrap
            anchors.right: parent.right
            font.pixelSize: 16
            readOnly: true

        }
        MouseArea{
            id: mouse
            anchors.fill: parent
            onClicked: {
                comments_page.loading();
                Variable.lien = "http://api.fmylife.com/account/infos?login="+author+"&key=4fd9d0cb0463c&language=fr";

                console.debug("[CommentDelegate] Chargement info user : \n" + Variable.lien);
                Variable.load_pages(pageStack,1); //1 = User MODE
            }
        }

    }
}

